from utils import datasets
from torchvision import transforms
import numpy as np
from matplotlib import pyplot as plt

transform = transforms.Compose([transforms.Resize(64), transforms.CenterCrop(64)])
# dataset = datasets.CUB(data_path=r'E:\desktop\data\cub', train=True, transform=transform)
# dataset = datasets.Dogs(data_path=r'E:\desktop\data\dogs',train=True,transform=transform)
dataset = datasets.Aircrafts(data_path=r'E:\desktop\data\airs', train=True, transform=transform)
index = np.random.randint(0, len(dataset), size=50)
imgs_labels = [dataset[i] for i in index]

if len(imgs_labels) == 1:
    plt.imshow(imgs_labels[0][0])
    plt.axis('off')
else:
    nrows, ncols = 5, 10
    fig, ax = plt.subplots(nrows, ncols, figsize=(ncols, nrows))
    for i in range(nrows * ncols):
        ax.flat[i].imshow(imgs_labels[i][0])
        ax.flat[i].axis('off')
plt.tight_layout()
plt.subplots_adjust(wspace=0, hspace=0)  # 调整子图间距
plt.show()
